home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 3 / Precision Software Applications Silver Collection Volume Three (PSM) (1993).iso / music2 / micfft10.arj / MICFFT.TXT < prev   
Text File  |  1993-01-27  |  11KB  |  207 lines

  1. MicFFT v1.0  -  January 27, 1993
  2. The PC Fourier Spectrum Analyzer
  3. by Craig M. Walsh
  4. CIS 70701-1614
  5. walsh@biovx1.dnet.nasa.gov
  6.  
  7. MicFFT is a program that allows PCs equipped with 8-bit 
  8. analog to digital converters (ADCs) on sound cards to 
  9. perform spectral analysis on pulse-code modulated (PCM) 
  10. signals.  With operation similar to octave spectrum 
  11. analyzers found on certain audio equalizers, MicFFT can be 
  12. used to view the frequency components of musical and vocal 
  13. signals, as well as a number of other types of signals that 
  14. can be input thru the ADC.  
  15.  
  16. Requirements:  MicFFT requires a fast computer equipped with 
  17. an EGA or VGA graphics adapter, a properly configured sound 
  18. card with an 8-bit ADC, and a curious computer user with an 
  19. interest in sound.  This program has been developed on a 
  20. 33Mhz 486 computer equipped with SVGA and a Covox 
  21. SoundMaster II sound card with a default ADC port address of 
  22. 22f (hex), but I believe other configurations should work if 
  23. the proper options are set.  For example, Sound Blaster 
  24. cards, etc. should also work, if the associated ADC port 
  25. address is known.
  26.  
  27. MicFFT v1.0 is freeware with a catch.  Anyone who uses the 
  28. program must advise me by sending a note via CompuServe mail 
  29. or over the Internet to the appropriate address listed 
  30. above.  I'd love to know what you think about the program 
  31. and what you are using it for, or perhaps to tell me what a 
  32. bunch of crap I'm shoveling in this document.  I uploaded 
  33. the program FileScop about a month ago to CompuServe 
  34. (MIDIFORUM) and nobody has written a single note about it, 
  35. although plenty have downloaded it.  I cannot improve on 
  36. these programs unless people give me ideas about them.  I 
  37. need information about problems, ideas etc.  Depending on 
  38. the response, I may not release programs into the public 
  39. domain in the future.  It just isn't worth it, unless...  
  40. Oi!  
  41.  
  42. The source code for this is not available without fee 
  43. however.  Contact me if you are interested in the methods 
  44. used and we can make arrangements.  MicFFT is written almost 
  45. entirely in Microsoft C (save the timer routines which are 
  46. written in assembly).  I may provide a Windows version of 
  47. the program, if I can get the performance up to par.
  48.  
  49.  
  50. What it does:    MicFFT takes PCM data sampled at a defined 
  51. rate and transforms the data using the Fast Fourier 
  52. Transform (FFT) from a time domain to frequency domain 
  53. representation.  When the program is running with the proper 
  54. setup, a plot window is presented that displays 128 
  55. frequency bands.  Below the plot window is a ruler that 
  56. displays 128 "ticks" representing each of the bands.  To 
  57. determine the frequency of each band, multiply the value of 
  58. the ruler tick (tens are shown in red, fives in orange and 
  59. ones in blue) by the Fundamental frequency listed at the 
  60. bottom of the screen.  For example, if the fundamental 
  61. frequency is 30Hz and the band of interest is tick 32, then 
  62. the frequency of that band is 960Hz.  Note that the 
  63. fundamental frequency is equal to the sampling frequency 
  64. divided by the number of points (256 in MicFFT).  Thus, if 
  65. the sampling frequency is 7680Hz, the fundamental will be 
  66. 30Hz.  This is also referred to as the "resolution" of the 
  67. spectrum, since values between this are not directly 
  68. calculated.  Note that the frequency bands plotted are 
  69. multiples of the fundamental and are thus scaled linearly.  
  70. Octave spectrum analyzers (of the type mentioned above) 
  71. scale the frequency data by powers of two.  Also note the 
  72. bandwidth (i.e. the lowest to highest frequencies) that can 
  73. be attained using any particular sampling frequency value.     
  74.  
  75. You will notice that the highest frequency that MicFFT 
  76. displays is half the sampling frequency.  In fact, all PCM 
  77. recording systems are limited to bandwidths of one-half the 
  78. sampling frequency.  The Nyquist sampling theorem dictates 
  79. that it is not possible to surpass this limit without 
  80. inducing "aliasing."  Aliasing is a sampling error that can 
  81. be likened to the common observation in the movie house of 
  82. wagon wheels that appear to rotate backwards in "Westerns."  
  83. Of course, the wheels are not turning backwards, but the 
  84. sampling rate of the projection system (24 frames/second) is 
  85. not fast enough to keep up with the movement of those 
  86. spokes, so we observe this backwards movement.  Aliasing is 
  87. a problem for PCM-sampled sound as well.  To ensure that 
  88. aliasing does not introduce problems in this arena, PCM-
  89. sampled sound always passes thru "anti-aliasing filters" 
  90. (which are very high slope low-pass filters) before the
  91. Nyquist limit.  Thus, in CD-quality sound applications 
  92. (where sound is sampled at 44.1 kHz), these low-pass
  93. filters begin attenuating sound at about 20 kHz, and have 
  94. attenuated most sound at the Nyquist limit of 22.05 kHz.
  95.  
  96. Since MicFFT does not have these sorts of anti-aliasing 
  97. filters built in, you will observe aliasing if you surpass 
  98. the Nyquist limit.  This will be seen when a signal of 
  99. increasing frequency moves toward the right end of the plot 
  100. and then begins to move toward the left again.  You should 
  101. thus be aware that complex waveforms with components
  102. that surpass this limit will
  103. not be accurately represented in the frequency plot.  To 
  104. avoid such problems, it is wise to choose the appropriate 
  105. bandwidth for a particular signal, assuming that the ADC can 
  106. keep up with the chosen sampling rate.  For speech, it is 
  107. usually sufficient to choose a sampling rate of about 10 
  108. kHz, but musical signals will require higher rates (perhaps 
  109. as high as 32 kHz before any degradation resulting from the 
  110. ADC speed becomes a problem).  Of course, aliasing can be an 
  111. interesting phenomenon unto itself, and you should consider 
  112. experimenting a bit with the sampling frequency on various 
  113. signals to see what is going on here.
  114.  
  115. Amplitude plotting modes:  It is possible to view amplitude 
  116. data in two ways with MicFFT.  The default is to represent 
  117. data logarithmically.  That is, the amplitudes plotted (i.e. 
  118. the y-axis) are scaled by a factor of log base 10.  This is 
  119. most useful for sound applications and results in a plot 
  120. similar to that observed on the octave-type spectrum 
  121. analyzer discussed above.  However, it is also possible to 
  122. view the data scaled linearly.  In this mode (using the flag 
  123. -m1 at the command line), the data will be scaled to the 
  124. maximum value returned by the FFT routine.  When the signal 
  125. data is zero or very low level, you will observe that the 
  126. fundamental frequency band is the highest.  This is due to 
  127. the fact that the FFT is returning a value here representing 
  128. a DC signal (i.e. not time-varying).  Maximum amplitude 
  129. scaling is perhaps more interesting to watch than log 
  130. scaling since it appears to be more sensitive to ambient 
  131. signals.  I'm not sure yet why this is (hey, I'm a molecular 
  132. biologist, not a math hack) just yet.  Anyway, if you have 
  133. an idea, just let me know.  Suffice it to say that low-level 
  134. signals will have amplitudes scaled appropriately by this 
  135. method for analysis, so long as background spectral 
  136. components do not overtake them.
  137.  
  138.  
  139. Usage:  MicFFT is designed to be run at the DOS prompt and 
  140. does not require additional parameters if the default setup 
  141. is appropriate for your system.  However, you may change the 
  142. following parameters by using command line flags that tell 
  143. MicFFT what defaults to change.  You can list these flags by 
  144. typing:
  145.     MicFFT -?
  146. Most likely, you will need to change the address of the ADC 
  147. port, if you are not using a Covox SoundMaster II with 
  148. factory defaults.  You will need to know the value of the 
  149. port address for your 8-bit ADC.  This can be supplied to 
  150. MicFFT in hexadecimal or decimal format using the -p flag.  
  151. If you use the hexadecimal address, be sure to follow this 
  152. number with an 'h' as this tells MicFFT to use a hexadecimal 
  153. port address.  Note that all flags (except the video mode 
  154. flags) require that values be entered after the flag with no 
  155. spaces (e.g. MicFFT -p24fh tells MicFFT to use hexadecimal 
  156. address 24f for the ADC port).
  157.  
  158. The sampling frequency can be changed with the -f flag.  You 
  159. should use a reasonable value here (i.e. greater than zero, 
  160. less than the maximum sampling rate of the ADC on your sound 
  161. card) otherwise the program will produce garbage and may 
  162. crash with a zero-divide error (I'm not sure why this 
  163. happens just yet).  Also, you must type all zeros (sorry 
  164. about that), so don't enter -f15kHz when you mean -f15000.
  165.  
  166. The video mode is set to use the maximum resolution mode of 
  167. your monitor.  This means that if you have a graphics card, 
  168. you should be able to use the program.  However, the program 
  169. was designed to run on EGA or VGA monitors, and the 
  170. justification of windows, etc. will not be correct for 
  171. monitors other than these.  The program may very well work 
  172. on Hercules compatible systems, although I've not tested 
  173. this.  On CGA systems, the screen is definitely not 
  174. justified properly, so it won't work well.  You can override 
  175. the default screen environment by typing -e or -v for EGA or 
  176. VGA mode.  You can use this on VGA monitors to force EGA 
  177. mode, which may increase the plot speed.  The EGA mode will 
  178. also increase the relative size of the plotting window and 
  179. may be more suited to your taste.  Experiment with this in 
  180. your environment to get the best performance.
  181.  
  182. Plotting modes are set by the -m flag as discussed above.  The
  183. default mode is -m0 (log base 10 scaling of the amplitudes).
  184.  
  185.  
  186. Applications:  Although I'm sure a number of you can think 
  187. of other things to do with MicFFT, I've used the program for 
  188. the following analyses with interesting results.  With a 
  189. sine-wave generator connected to the input port, I was able 
  190. to test the accuracy of the program.  To my knowledge, the 
  191. timing routines are fairly accurate, and the program's 
  192. accuracy was verified (at least in the audio spectrum) at a 
  193. number of discrete frequencies using this method.  Thus, 
  194. MicFFT's accuracy makes it useful for analysis of real world 
  195. signals.  The program would be useful for analysis of 
  196. musical signals.  It should be possible to analyze samples 
  197. of a particular musical instrument to observe the various 
  198. frequency components generated.  For those interested in 
  199. speech recognition, the program is able to display frequency 
  200. components of various formant sounds.  On a fast computer, 
  201. it can even act as a sort of octave-spectrum analyzer 
  202. (although not currently scaled in octaves) for musical 
  203. signals.
  204.  
  205. Have fun and let me know what you think.
  206. Craig Walsh
  207.